/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package net.worlds.object;

import java.util.logging.Level;
import java.util.logging.Logger;
import net.worlds.WorldsException;
import net.worlds.Main;


public class Storage extends GameObject{
    public Storage() throws WorldsException
    {
        super("Storage");
    }
    @Override
    public void addChild(final GameObject c) throws WorldsException
    {
        super.addChild(c);
        Runnable r = new Runnable()
        {
            public void run() {
                c.disable();
                if(c instanceof Part)
                    ((Part)c).getBody().resetFiltering();
                else if(c instanceof Model)
                    ((Model)c).resetFiltering();
            }
        };
        if(c.isInWorld())
            r.run();
        else
            Main.addStepTask(r);
    }
    @Override
    public void removeChild(final GameObject c)
    {
        super.removeChild(c);
        Runnable r = new Runnable()
        {
            public void run() {
                c.enable();
                if(c instanceof Part)
                    ((Part)c).getBody().resetFiltering();
                else if(c instanceof Model)
                    ((Model)c).resetFiltering();
            }
        };
        if(c.isInWorld())
            r.run();
        else
            Main.addStepTask(r);
    }
}
